/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Beans;

import java.io.FileInputStream;
import java.io.InputStream;
import javax.faces.bean.ManagedBean;
import javax.faces.bean.SessionScoped;
import javax.faces.context.FacesContext;
import javax.servlet.ServletContext;

import org.primefaces.model.DefaultStreamedContent;
import org.primefaces.model.StreamedContent;

/**
 *
 * @author Pedro
 */
@ManagedBean    
@SessionScoped 
public class FileDownloadController {

    private StreamedContent file;

    public FileDownloadController() {
        InputStream stream = ((ServletContext)FacesContext.getCurrentInstance().getExternalContext().getContext()).getResourceAsStream("/Especificação do Projeto.pdf");  
        file = new DefaultStreamedContent(stream, "WebApplication/pdf", "Especificação_do_Projeto.pdf");
    }

    public StreamedContent getFile() {
        return file;
    }
}
